package edu.objects;

import java.io.Serializable;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

/**
 * Holds a Tile
 * @author Luke Bryan
 *
 */
@PersistenceCapable
public class Tile implements Serializable{
	
	
	@Persistent
	private char _letter;
	@Persistent
	private int _value;
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
	
	
	public void setKey(Key key) {
        this.key = key;
    }
	
	
	public Tile(char value, boolean blankTile) {
		_letter = value;
		if (blankTile) {
			_value = 0;
		} else {
			//_value = new LetterBag().getPointValue(_letter);
		}
	}
	
	/**
	 * Returns the letter as a char.
	 * @return
	 */
	public char getLetter() {
		return _letter;
	}
	
	public boolean isBlank() {
		return (_value==0);
	}
	
	/**
	 * Returns the point value of the letter, 0 if this is actually a blank tile.
	 * @return
	 */
	public int getValue() {
		return _value;
	}
	
	public String toString() {
		return _letter+","+_value;
	}
}
